//
//  TLS_TcomunityCell.m
//  Travel_World
//
//  Created by lanou on 15/10/13.
//  Copyright © 2015年 TLS. All rights reserved.
//

#import "TLS_TcomunityCell.h"
#import "TLS_TcoumnityModel.h"

@implementation TLS_TcomunityCell
+ (instancetype)coumnityCellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"coumnityCell";
    TLS_TcomunityCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[TLS_TcomunityCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photoImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_photoImageView];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_nameLabel];
        
        self.total_threadsLael = [[UILabel alloc] init];
        self.total_threadsLael.font = [UIFont systemFontOfSize:15];
        self.total_threadsLael.textColor = [UIColor grayColor];
        [self.contentView addSubview:_total_threadsLael];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.photoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        make.right.equalTo(self.nameLabel.mas_left).offset(-10);
        make.width.equalTo(@80);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.height.equalTo(@30);
    }];
    [self.total_threadsLael mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.left.equalTo(self.photoImageView.mas_right).offset(10);
        make.height.equalTo(@30);
    }];
}
- (void)setCoumentyModel:(TLS_TcoumnityModel *)coumentyModel
{
    if (_coumentyModel != coumentyModel) {
        _coumentyModel = coumentyModel;
    }
    [self.photoImageView sd_setImageWithURL:[NSURL URLWithString:coumentyModel.photo] placeholderImage:[UIImage imageNamed:@"WplaceImage.jpg"]];
    self.nameLabel.text = coumentyModel.name;
    self.total_threadsLael.text = [NSString stringWithFormat:@"%@个帖子",coumentyModel.total_threads];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
